package robocup.component.tactics;

import robocup.component.SConf;
import robocup.component.ControllerNumbers.STAMINA_LEVEL;
import robocup.component.actionfactories.BasicActionFactory;
import robocup.component.geometry.Vektor;

public class BeforeKickOffState
    extends AbstractState {

  /**
   * BeforeKickOffState is used for all players but nr. 10 and lets them turn to
   * the opp. goal.
   * 
   * @param parent
   */
  public BeforeKickOffState(
      final StateEvaluation parent) {

    super(parent);
    this.state = STATES.BEFORE_KICKOFF;
  }

  @Override
  public boolean preCondition() {

    return this.checkPlayMode() && !this.checkIAmFastestToBall() && !this
        .getWorld().canKick();
    // && wm.getSelfRef().getAngleRel(wm.getSConf().GOAL_POS_OTHER,
    // Player.RELATIVE.TO_BODY) > 10;
  }

  /**
   * This state will always succeed.
   */
  @Override
  protected double successProbability() {

    return 1;
  }

  /**
   * Because this is a dummy state - the values for assessment are very low!
   */
  @Override
  protected double successBenefit() {

    return 1;
  }

  @Override
  public void calculateMainAction() {

    final Vektor lookHere = SConf.getInstance().GOAL_POS_OTHER;

    // sometimes we don't hear the play on command -> try dashing with max
    // stamina level for number 10
    if (this.getPlayer().getNumber() == 10) {
      this.mainAction = BasicActionFactory.moveToPos(this.getPlayer(),
          new Vektor(), 1, STAMINA_LEVEL.MAX);
    }
    else {
      this.mainAction = BasicActionFactory.turnBodyToPoint(this.getWorld(),
          lookHere);
    }
  }

}

/**
 * $Log: BeforeKickOffState.java,v $ Revision 1.5 2006/11/05 13:58:02 wetzker
 * more merging - CLang + MF + some states still missing
 * 
 * Revision 1.4 2006/05/23 17:40:02 wetzker added new dribbling (still much to
 * do but better than before :-) added new role-model (see player.java) debugged
 * clear ball, kickNRun,Passing, InterceptBall, NR
 * 
 * Revision 1.3 2006/03/26 21:58:40 wetzker created geometry package and moved
 * geometry classes from worldobject package there
 * 
 * Revision 1.2 2006/03/26 20:09:59 wetzker each player now contains its known
 * states and the playmodes of each state
 * 
 * Revision 1.1 2006/03/13 07:36:27 axle moved from ROOT/src for Maven 2
 * Buildsystem and Team/Soccerscope separation
 * 
 * Revision 1.9 2006/03/07 12:46:11 endert Merge after refactoring: - New
 * State-Interface: One Method for each action type - Action Bean removed -
 * ActionFactorys for helper methods, States calculate main-Action themselves -
 * formatted code - added State-List in Monitor (Context-Menu of Player) - other
 * smaller stuff
 * 
 * Revision 1.8.2.3 2006/02/28 16:58:04 endert Organized imports, outsourced
 * unused vars, removed warnings!
 * 
 * Revision 1.8.2.2 2006/02/28 16:43:06 endert Changed State-Interface:
 * -resetState() -calculateXYAction() Usage of ActionFactories (no higher level
 * actions, these should be calculated in calculateMainAction()), Set
 * getAction() to deprecated and retactoring of variable names (wm ->
 * getWorld())
 * 
 * Revision 1.8.2.1 2006/02/25 22:07:20 wetzker formated
 * 
 * Revision 1.8 2006/02/24 18:53:49 wetzker used enums for Play_modes and
 * Referee_messages - still has to be improved after creation of new
 * Play_mode-Model - tagged old version removed millions of warnings
 * 
 * Revision 1.7 2006/02/22 16:04:30 endert This is done: - Rebound SoccerScope
 * to Agents (can be added or removed in config-file) - Situations now all
 * extend abstract class Situation - Refactorings: ActionBean _ removed from
 * Attributes - SoccerScope will automatically connect to host given in
 * Start-Call - Trainer uses the same host as soccerscope - Removed unused stuff
 * (old confs, bat, etc.) - Code formatted (good luck when merging) - organized
 * imports - all that i forgot to mention here Revision 1.6 2006/02/08 17:30:25
 * gamel run free is jetz drinne
 * 
 * Revision 1.5 2006/02/06 20:42:53 endert New Say-Method in Action Bean, which
 * is called after execAcion in StateEvaluation
 * 
 * Revision 1.4 2006/02/06 18:11:18 wetzker refactored, farmatted and cleaned
 * the states Revision 1.3 2006/02/02 22:48:02 gamel added for new goalie
 * 
 * Revision 1.2.36.1 2005/12/15 23:59:29 gamel new version of goalie splitted
 * into many states and replaced many action-predictions with geometry - there
 * are many bugs inside until now, so beware
 * 
 * Revision 1.2 2005/09/09 12:36:45 endert New Defense (Branch) with simple
 * back-four merged into head!
 * 
 * Revision 1.1 2005/09/01 10:22:48 wetzker + expectedPlayers[] - by now same as
 * allPlayers except for the player that is fastest to ball - if you got
 * information about players behaviour save it here!! corrected collision bug
 * improved passing and ball interception for near balls some changes for a
 * better performance
 * 
 * Revision 1.4 2005/08/16 16:26:33 wetzker merged composite branch
 * 
 * Revision 1.3.2.2 2005/08/16 15:43:26 wetzker removed ball and player cloning
 * in getSelf, getBall -> should be much faster now merged with changes from
 * head
 * 
 * Revision 1.3.2.1 2005/07/15 19:23:26 wetzker continued refactoring of WM +
 * ball prophecy now in ball class - removed visual cycle; added body cycle
 * +WM.getAge(DynamicObject) +WM.getReliability(DynamicObject, maxAge)
 * 
 * Revision 1.3 2005/06/29 11:45:59 gamel moved Enum STATES from ActionBean to
 * AbstractState
 * 
 * Revision 1.2 2005/06/28 20:07:56 till some inprovements
 * 
 * Revision 1.1 2005/06/28 16:24:30 till created LookToBallState. => dai 5:0
 * a4ty instead of 3:0 during a game of 2000 cycles
 * 
 * 
 */
